import Loading from 'element-ui/packages/loading';

export default {

  data() {
    return {
      loading: false
    };
  },

  methods: {
    startLoading() {
      this.$nextTick(() => {
        if (this.$el.className.indexOf('el-dialog') > -1) {
          this.loadingInstance = Loading.service({target: this.$el.children[0]});
        } else {
          this.loadingInstance = Loading.service({target: this.$el});
        }
      });
    },

    closeLoading() {
      this.loadingInstance.close();
    }
  }

};
